const snapshotPage = new Vue({
    el: '#snapshot',
    data: {
        accessTime: '',
        pageContext: ''
    },
    methods: {
        async initData() {
            //根据url获取页面快照
            const insType = this.getUrlParam("insType");
            const url = this.getUrlParam("url");
            const type = parseInt(insType);
            //监测指令
            if (type === 1) {
                const res = await slogMonitorLogApi.getSnapshot({url: url})
                this.pageContext = res.pageContent;
                this.accessTime = TableColumn.datetimeFormat('', '', res.accessTime);
                //过滤指令
            } else if (type === 2) {
                const res = await slogFilterLogApi.getSnapshot({url: url})
                this.pageContext = res.pageContent;
                this.accessTime = TableColumn.datetimeFormat('', '', res.accessTime);
            }
        },
        getUrlParam(paraName) {
            var url = document.location.toString();
            var arrObj = url.split("?");

            if (arrObj.length > 1) {
                var arrPara = arrObj[1].split("&");
                var arr;

                for (var i = 0; i < arrPara.length; i++) {
                    arr = arrPara[i].split("=");

                    if (arr != null && arr[0] == paraName) {
                        return arr[1];
                    }
                }
                return "";
            } else {
                return "";
            }
        }
    },
    mounted: async function () {
        await this.initData();
    },
})